from classifiers.SVM import SVM
from dataset.DatasetImplementations import DatasetForLibSVM

data = DatasetForLibSVM()
training_set = data.get_training_set()
validation_set = data.get_validation_set()
test_set = data.get_test_set()
l = len(training_set)
print 'lenght training_set ',l
output = open('../data/learning_curve.dat','w')
output.write('x\tJt\tJc\tJtest\n')
i=0
increment=10
while(i<l):
	i=i+increment
	print 'x=', i
	subset = training_set[0:i]
	svm = SVM()
	svm.train(subset)
	Jtraining= 100-svm.test(training_set)[0]
	Jcrossvalidation =100- svm.test(validation_set)[0]
	Jtest =100- svm.test(test_set)[0]
	output.write(str(len(subset))+'\t'+str(Jtraining)+'\t'+str(Jcrossvalidation)+'\t'+str(Jtest)+'\n')
	
output.close()


